package com.deng.etl.view
{
	import com.deng.etl.vo.EtlValidVo;
	
	import flash.events.MouseEvent;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.controls.Button;
	import mx.events.FlexEvent;
	import mx.managers.PopUpManager;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.mxml.RemoteObject;

	public class EtlWorkloadValidHisBT extends Button
	{
		private var selVo:EtlValidVo;
		public function EtlWorkloadValidHisBT()
		{
			this.addEventListener(FlexEvent.CREATION_COMPLETE,showHandler);
			this.addEventListener(FlexEvent.SHOW,showHandler);
			this.addEventListener(MouseEvent.MOUSE_UP,upEvt);
			super();
			this.label = "请选择......";
			
		}
		private function upEvt(event:MouseEvent):void{	
			var ro:RemoteObject = new RemoteObject();
			ro.destination = "HisOrganizationImpl";
			ro.addEventListener(ResultEvent.RESULT,searchRst);
			ro.addEventListener(FaultEvent.FAULT,flt);
			ro.getHisByOrganizationId(selVo.organization_id);			
		}
		
		private function searchRst(rst:ResultEvent):void{
			var tw:EtlWorkloadHisTW = EtlWorkloadHisTW(PopUpManager.createPopUp(this.parent, EtlWorkloadHisTW , true));
			tw.setParentItem(rst.result as ArrayCollection);
			PopUpManager.centerPopUp(tw);
		}
		private function flt(evt:FaultEvent):void{
			Alert.show(evt.fault.getStackTrace());
		}
		private function showHandler(evt:FlexEvent):void{
			selVo = this.data as EtlValidVo;
		}
	}
}